﻿using Super.Collection.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Super.Collection.Core.Providers.Sports
{
    /// <summary>
    /// 中国体彩网（http://www.lottery.gov.cn）
    /// </summary>
    public class ChinaSportsLotteryNet : DataProvider, IProvider
    {
        public override List<Announcement> GetAnnouncements(string url, Encoding encoding)
        {
            List<string> serialNumbers = GetSerialNumber(url, encoding);
            return null;
        }

        /// <summary>
        /// 获取发行期号
        /// </summary>
        /// <returns></returns>
        private List<string> GetSerialNumber(string url, Encoding encoding)
        {
            List<string> serialNumbers = new List<string>();
            string document = this.GetDocument(url, encoding);
            MatchCollection matchCollections = Regex.Matches(document, @"(?<=>)(?'serialNumber'\d{3,})(?=<\/option>)", RegexOptions.IgnoreCase);
            for (int i = 0; i < matchCollections.Count; i++)
            {
                serialNumbers.Add(matchCollections[i].Groups["serialNumber"].Value);
            }
            return serialNumbers;
        }

		public override NLotteryDraw GetLatestLotteryDraw()
		{
			throw new NotImplementedException();
		}
	}
}
